package com.yanqu.road.server.cmd.activity.peakstronghold;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.peakstronghold.config.PeakStrongHoldConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakStrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.peakstronghold.PeakStrongholdActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_PEAK_STRONGHOLD_ELIMINATION_REPORT,desc = "获取淘汰赛联盟战报")
public class PeakStrongholdGetEliminateReportCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        PeakStrongHoldConfig config = PeakStrongholdActivityMgr.getConfig();
        if (config == null || !ActivityMgr.activityInShowTime(config.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
            return;
        }

        if (!PeakStrongholdActivityMgr.canUnionInBattle(player.getUserInfo().getUnionUid())) {
            ret = GameErrorCode.E_PEAK_HOLD_NOT_IN_ELIMINATE;
            return;
        }
        int activityId = config.getActivityInfo().getActivityId();
        PeakStrongholdWarProto.GetPeakEliminateUnionReportReqMsg req = PeakStrongholdWarProto.GetPeakEliminateUnionReportReqMsg.parseFrom(packet.getBytes());
        PeakStrongholdWarProto.CrossGetEliminateUnionReportReqMsg.Builder msg = PeakStrongholdWarProto.CrossGetEliminateUnionReportReqMsg.newBuilder();
        msg.setActivityId(activityId);
        msg.setType(req.getType());
        msg.setUnionId(req.getUnionId());
        player.sendUnionActivityGroupPacket(Protocol.C_PEAK_STRONGHOLD_ELIMINATION_REPORT, msg, activityId);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
